﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C = System.Console;

namespace Edu.Console
{
    public class Enums
    {
        const string Manager = "Manager";

        static void RefParams(params string[] a)
        {
            // a.GetType() = string[]
            C.WriteLine("Params - Length = {0}", a.Length);
        }

        static void RefParams(string s, params string[] a)
        {
            // a.GetType() = string[]
            C.WriteLine("String - Params - Length = {0}", a.Length);
        }

        static void TestParams()
        {
            RefParams("123");
            RefParams();
            RefParams("123", "456", "789");
            RefParams(new[] { "444", "555" });

        }


        static EmployerStatus GetEmployerStatus(int id)
        {
            switch (id)
            {
                case 1: return EmployerStatus.Employer;
                case 2: return EmployerStatus.Employer;
                case 3: return EmployerStatus.Assistant;
                case 4: return EmployerStatus.Manager;
                case 5: return EmployerStatus.Stuff;
                case 6: return EmployerStatus.Stuff;
                case 7: return EmployerStatus.CEO;
            }
            return EmployerStatus.NonEmployer;
        }

        static void TestEmployer(int id)
        {
            var status = GetEmployerStatus(id);
            C.WriteLine("Employer {0} {1} = {2}",id, status, (int)status);
        }

        static void TestEnums()
        {
            TestEmployer(1);
            TestEmployer(3);
            TestEmployer(5);
            TestEmployer(6);
            TestEmployer(7);
            C.WriteLine("base type = {0}", Enum.GetUnderlyingType(typeof(EmployerStatus)));
            var values = Enum.GetValues(typeof(EmployerStatus));
            foreach (var value in values)
            {
                C.WriteLine("enumerator {0} {0:D}", value);
            }
            var statusStringFromDatabase = "CEO";

            EmployerStatus parsedStatus = (EmployerStatus) Enum.Parse(typeof(EmployerStatus), statusStringFromDatabase);

            C.WriteLine("From DB ={0} Parsed={1}:{1:D}", statusStringFromDatabase, parsedStatus);
        }

        public static void Lesson()
        {
            TestParams();
            TestEnums();
        }
    }
}
